#ifndef __THREAD_POOL_H__
#define __THREAD_POOL_H__

#include <atomic>
#include <condition_variable>
#include <functional>
#include <mutex>
#include <queue>
#include <thread>
#include <vector>
class ThreadPool
{
  public:
    ThreadPool(const int threadNums);
    ~ThreadPool();

  public:
    void addTask(std::function<void()> task);

  private:
    void threadFun();

    std::vector<std::thread> threads;

    std::mutex mtx;
    std::queue<std::function<void()>> tasks;
    std::condition_variable conditions;
    std::atomic<bool> stop{false};
};

#endif  // __THREAD_POOL_H__